home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / patches / pgs3h21d.lha / 3.0h2update / Macros.LHA / PrintSignature.rexx < prev    next >
OS/2 REXX Batch file  |  1995-09-21  |  6KB  |  216 lines

  1. /* $VER: PrintSignature.rexx 1.1 (13.9.95)
  2.    Copyright 1995 Soft-Logik Publishing Corporation
  3.    May not be distributed without Soft-Logik Publishing Corporation's express written permission */
  4.  
  5. OPTIONS RESULTS
  6. ADDRESS 'PAGESTREAM'
  7.  
  8.  
  9. /* MAIN LOOP */
  10. call OPENLIBS()
  11.  
  12.     iTemp = GETDOCINFO()                            /* get msys and page size */
  13.  
  14.     if iTemp = 0 then do
  15.  
  16.         iTemp = SIGREQ()                            /* get creep from user */
  17.         if iTemp = 0 then do
  18.             if dCreep > 0 then call CALCCREEP()        /* calculate creep */
  19.             call OPENBUSY()
  20.             call CHANGESIZE()                        /* double the document width */
  21.             'refresh wait'
  22.             call MOVEONPAGE()                        /* move objects to correct page sides */
  23.             call MOVETOPAGE()                        /* move objects to correct spreads */
  24.             call CLOSEBUSY()
  25.             'refreshwindow'
  26.             'refresh continue'
  27.         end
  28.  
  29.     end
  30.  
  31. EXIT
  32.  
  33. GETDOCINFO:
  34. /* LET'S CHECK OUT THE DOCUMENT */
  35.  
  36.     /* IS A DOCUMENT OPEN? */
  37.     sError = 'A document must be open to use this macro.'
  38.     signal on error
  39.     currentdocument
  40.  
  41.     /* GET PAGE COUNT */
  42.     'getpagenumbering 'aPage
  43.  
  44.     /* IS THE PAGE COUNT DIVISABLE BY 4? */
  45.     sError = 'The page count must be a multiple of four to use this macro.'
  46.     if trunc(aPage.length/4) ~= aPage.length/4 then signal error
  47.  
  48.     /* GET PAGE SIZE */
  49.     'getpagemasterpage masterpage 'sMpage' page 1'
  50.     'getdimensions 'aMpage' masterpage "'sMpage'"'
  51.     sMsys = msys(aMpage.width)
  52.     dMpageX = p2d(aMpage.width,'pt')
  53.     dMpageY = p2d(aMpage.height,'pt')
  54.  
  55.     /* GET DOCUMENT NAME. CREATE SIGNATURE NAME */
  56.     'currentdocument'
  57.         aDoc.name = result
  58.         aDoc.tname = aDoc.name
  59.     if length(aDoc.name) > 20 then aDoc.tname = left(aDoc.name,20)
  60.         aSig.name = aDoc.tname||'.signature'
  61.  
  62.     /* CALCULATE THE SPREAD SIZE */
  63.     dSpageX = 2 * dMpageX
  64.     dSpageY = dMpageY
  65.  
  66. RETURN 0
  67.  
  68. SIGREQ:
  69. /* PRINT SIGNATURE REQUESTER */
  70. rcode=0
  71.  
  72.     /* ALLOCATE REQUESTER */
  73.     allocarexxrequester '"Print Signature"' 338 71
  74.         hSigReq=result
  75.  
  76.     /* ADD GADGETS */
  77.     addarexxgadget hSigReq EXIT 12 54 70 label "_Ok"
  78.         hOkGadget=result
  79.     addarexxgadget hSigReq EXIT 256 54 70 label "_Cancel"
  80.         hCancelGadget=result
  81.     addarexxgadget hSigReq TEXT 8 8 80 border none string "Signature"
  82.     sMpageX = p2d(dSpageX'pt',sMsys)
  83.     sMpageY = p2d(dSpageY'pt',sMsys)
  84.     addarexxgadget hSigReq TEXT 100 8 106 border recessed label "_Horz" string sMpageX||sMsys
  85.     addarexxgadget hSigReq TEXT 220 8 106 border recessed label "_Vert" string sMpageY||sMsys
  86.     addarexxgadget hSigReq STRING 44 28 162 label "'Paper C_reep'" string '0"'
  87.         hCreepGadget=result
  88.  
  89.     /* SHOW REQUESTER */
  90.     doarexxrequester hSigReq
  91.     if result=hCancelGadget then rcode=9
  92.     else do
  93.         /* GET GADGET STATUS */
  94.         getarexxgadget hSigReq hCreepGadget string
  95.             dCreep=result
  96.         if dCreep=p2d(dCreep) then dCreep=dCreep||sMsys
  97.             dCreep=p2d(dCreep,'pt')
  98.     end
  99.  
  100.     /* FREE REQUESTER */
  101.     freearexxrequester hSigReq
  102.     freearexxlist hSignatureList
  103.  
  104. RETURN rcode
  105.  
  106. CALCCREEP:
  107. /* CALCULATE CREEP OFFSET */
  108.  
  109. dcreep=3/32
  110.     iStart = 1                                                    /* define start/end values */
  111.     iEnd = aPage.length
  112.     iHalf= aPage.length / 2
  113.  
  114.     aCreep.iStart = 0                                            /* zero creep for start and end */
  115.     aCreep.iEnd = 0
  116.  
  117.     dCreep = dCreep / (aPage.length/4 - 1)                        /* calculate incremental creep value */
  118.  
  119.     do i = iStart+1 to iEnd-1                                    /* repeat for all pages except first and last */
  120.         if i <= iHalf then aCreep.i = trunc((i-iStart)/2)*dCreep
  121.         if i > iHalf then aCreep.i = trunc((iEnd-i)/2)*dCreep
  122.     end i
  123.  
  124.     do i = 1 to iEnd
  125.         aCreep.i = p2d(aCreep.i,'pt')
  126.     end i
  127.  
  128. RETURN
  129.  
  130. CHANGESIZE:
  131. /* CREATE THE SIGNATURE */
  132.     'setdocumentname 'aSig.name' document 'aDoc.name
  133.     'setdimensions 'dSpageX'pt 'dSpageY'pt portrait single masterpage "'sMpage'"'
  134. RETURN
  135.  
  136. MOVEONPAGE:
  137. /* MOVE OBJECTS TO CORRECT PAGE SIDES AND SHIFT FOR CREEP */
  138.  
  139.     do i = 1 to aPage.length by 2                    /* repeat for each odd page */
  140.         if dCreep = 0 then aCreep.i = 0
  141.         'selectobject all page 'i
  142.         dOffset = dMpageX - aCreep.i
  143.         'move offset 'dOffset'pt '0'pt nosnap'
  144.         iBRcurrent = iBRcurrent + 1
  145.         call setbusy(iBRcurrent/iBRtotal*100)
  146.     end i
  147.  
  148.     do i = 2 to aPage.length by 2                    /* repeat for each even page */
  149.         if dCreep = 0 then aCreep.i = 0
  150.         'selectobject all page 'i
  151.         'move offset 'aCreep.i'pt '0'pt nosnap'
  152.         iBRcurrent = iBRcurrent + 1
  153.         call setbusy(iBRcurrent/iBRtotal*100)
  154.     end i
  155.  
  156. RETURN
  157.  
  158. MOVETOPAGE:
  159. /* MOVE OBJECTS TO CORRECT SPREADS */
  160.  
  161.     do i = aPage.length to (aPage.length/2)+1 by -1        /* repeat for all pages > page.count/2 */
  162.         'selectobject all page 'i
  163.         'movetopage page 'aPage.length-(i-1)
  164.         iBRcurrent = iBRcurrent + 1
  165.         call setbusy(iBRcurrent/iBRtotal*100)
  166.     end i
  167.  
  168. RETURN
  169.  
  170. OPENLIBS:
  171.     /* OPEN LIBRARIES */
  172.     IF ~SHOW('L','rexxsupport.library') THEN
  173.         call addlib('rexxsupport.library',0,-30)
  174.     IF ~SHOW('L','softlogik:libs/slarexxsupport.library') THEN
  175.         call addlib("softlogik:libs/slarexxsupport.library", 0, -30)
  176. RETURN
  177.  
  178. DOALERT:
  179. parse arg sAlertText
  180. iAlertLength=length(sAlertText)
  181. /* Display an alert requester */
  182.     allocarexxrequester '"Macro Alert"' iAlertLength*8+24 55
  183.         hAlertReq=result
  184.     addarexxgadget hAlertReq TEXT 8 12 iAlertLength*8+8 border none string '"'sAlertText'"'
  185.     addarexxgadget hAlertReq EXIT iALertLength*8-58 38 70 label "_Exit"
  186.     doarexxrequester hAlertReq
  187.     freearexxrequester hAlertReq
  188. RETURN
  189.  
  190. OPENBUSY:
  191.     openbusyrequester message "'Preparing Signature...'" thermometer enabled abort enabled total 100 current 0
  192.         hBusyReq=result
  193.     iBRcurrent = 0
  194.     iBRtotal = aPage.length * 1.5
  195. RETURN
  196.  
  197. SETBUSY:
  198.     parse arg value
  199.     setbusyrequester hBusyReq current value
  200.     getbusyrequester hBusyReq
  201.     if result=1 then do
  202.         call closebusy()
  203.         exit
  204.     end
  205. RETURN 0
  206.  
  207. CLOSEBUSY:
  208.     'closebusyrequester 'hBusyReq
  209. RETURN
  210.  
  211. ERROR:
  212. /* TRAP ERRORS */
  213.     call doalert(sError)
  214.  
  215. RETURN 9
  216.